//
//  SFExpandableTableViewSelectedCell.m
//  TableViewFramework
//
//  Created by 支晓辉 on 16/3/24.
//  Copyright © 2016年 wishselfly. All rights reserved.
//

#import "SFExpandableTableViewSelectedCell.h"

@interface SFExpandableTableViewSelectedCell ()
/** 标题文本 */
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
/** 头像图像视图 */
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
/** 选择按钮 */
@property (weak, nonatomic) IBOutlet UIButton *selectedButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutSelectedButtonWidth;

@end

@implementation SFExpandableTableViewSelectedCell

#pragma mark - Getters

- (NSString *)title {
    return self.titleLabel.text;
}

- (BOOL)isSelected {
    return self.selectedButton.selected;
}

- (UIImage *)headImage {
    return self.headImageView.image;
}

- (BOOL)showHeadImageView {
    return !self.headImageView.hidden;
}

- (BOOL)showSelectedButton {
    return !self.selectedButton.hidden;
}

- (BOOL)checked {
    return self.selectedButton.selected;
}

#pragma mark - Setters

- (void)setTitle:(NSString *)title {
    self.titleLabel.text = title;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:NO animated:animated];
}

- (void)setSelected:(BOOL)selected {
    [super setSelected:NO];
}

- (void)setHeadImage:(UIImage *)headImage {
    self.headImageView.image = headImage;
}

- (void)setShowHeadImageView:(BOOL)showHeadImageView {
    self.headImageView.hidden = !showHeadImageView;
}

- (void)setShowSelectedButton:(BOOL)showSelectedButton {
    self.selectedButton.hidden = !showSelectedButton;
    self.layoutSelectedButtonWidth.constant = showSelectedButton ? 32.f:10.f;
}

- (void)setChecked:(BOOL)checked {
    self.selectedButton.selected = checked;
}

@end
